home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / progjour / 1991 / 04 / v_putc.c < prev    next >
C/C++ Source or Header  |  1991-05-03  |  1KB  |  41 lines

  1. /* v_putc.c- Write Character to Viewport */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <conio.h>
  6. #include <tools/viewport.h>
  7.  
  8. int v_putc( viewport *v, int c, int move )
  9. {
  10.     /* Overwrite the character on which the viewport's cursor is
  11.      * resting. The cursor position advances one notch if the move
  12.      * argument is true. It won't move past the right edge of the
  13.      * line, however. Note that all characters are printed literally,
  14.      * \n yields a graphics character, it doesn't go to the next line.
  15.      * Return true if the cursor moved (it won't at end of line),
  16.      * false otherwise.
  17.      */
  18.  
  19.     int outc;
  20.     int col, row;
  21.  
  22.     if( v->magic != VMAGIC )
  23.         return 0;
  24.  
  25.     if( v->inactive )
  26.         v_open( v );
  27.  
  28.     /* output the character. Can't use putch() both because we
  29.      * don't have enough control of the color and because it
  30.      * screws up the cursor if we're writing to the bottom right
  31.      * corner of the screen.
  32.      */
  33.  
  34.     outc = (c & 0xff) | ((v->bcolor << 4 | v->fcolor) << 8);
  35.     col  = v->col + v->cur_col + 1;
  36.     row  = v->row + v->cur_row + 1;
  37.     puttext( col, row, col, row, &outc );
  38.  
  39.     return( move ? v_advance(v) : 0 );
  40. }
  41.